from the unit.
}
}
+static int
+waypt_read_cb(int total_ct, GPS_PWay *way)
+{
+ static int i;
+
+ if (global_opts.verbose_status) {
+ i++;
+ waypt_status_disp(total_ct, i);
+ }
+}
+
static void
waypt_read(void)
{
return;
}
- if ((n = GPS_Command_Get_Waypoint(portname, &way)) < 0) {
+ if ((n = GPS_Command_Get_Waypoint(portname, &way, waypt_read_cb)) < 0) {
fatal(MYNAME ":Can't get waypoint from %s\n", portname);
}
return way;
}
+
static int
waypt_write_cb(GPS_PWay *way)
{
if (global_opts.verbose_status) {
i++;
- fprintf(stdout, "%d/%d/%d\r", i*100/n, i, n);
- fflush(stdout);
+ waypt_status_disp(n, i);
}
return 0;
}
**
** @return [int32] number of waypoint entries
************************************************************************/
-int32 GPS_A100_Get(const char *port, GPS_PWay **way)
+int32 GPS_A100_Get(const char *port, GPS_PWay **way, int (*cb)())
{
static UC data[2];
int32 fd;
return gps_errno;
if(!GPS_Send_Ack(fd, &tra, &rec))
return gps_errno;
-
switch(gps_waypt_type)
{
case pD100:
GPS_Error("A100_GET: Unknown waypoint protocol");
return PROTOCOL_ERROR;
}
+ /* Issue callback for status updates. */
+ if (cb) {
+ cb(n, &((*way)[i]));
+ }
}
if(!GPS_Packet_Read(fd, &rec))
int32 GPS_Init(const char *port);
-int32 GPS_A100_Get(const char *port, GPS_PWay **way);
+int32 GPS_A100_Get(const char *port, GPS_PWay **way, int (*cb)(int ct, GPS_PWay *));
int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n, int (*cb)(GPS_PWay *));
int32 GPS_A200_Get(const char *port, GPS_PWay **way);
** @return [int32] number of waypoint entries
************************************************************************/
-int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way)
+int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way, int (*cb)())
{
int32 ret=0;
switch(gps_waypt_transfer)
{
case pA100:
- ret = GPS_A100_Get(port,way);
+ ret = GPS_A100_Get(port,way, cb);
break;
default:
GPS_Error("Get_Waypoint: Unknown waypoint protocol");
int32 GPS_Command_Get_Track(const char *port, GPS_PTrack **trk);
int32 GPS_Command_Send_Track(const char *port, GPS_PTrack *trk, int32 n);
-int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way);
+int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way,int (*cb)());
int32 GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n, int (*cb)());
int32 GPS_Command_Get_Proximity(const char *port, GPS_PWay **way);
/*
Communicate Thales/Magellan serial protocol.
- Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+ Copyright (C) 2002, 2003, 2004 Robert Lipe, robertlipe@usa.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static char *bs;
static char *noack;
static int route_out_count;
+static int waypoint_read_count;
typedef enum {
mrs_handoff = 0,
}
if (strncmp(ibuf, "$PMGNWPT,", 7) == 0) {
waypoint *wpt = mag_wptparse(ibuf);
+ waypoint_read_count++;
+ waypt_status_disp(waypoint_read_count, waypoint_read_count);
switch (global_opts.objective)
{
case wptdata:
mag_rd_init(const char *portname)
{
time_t now, later;
+ waypoint_read_count = 0;
if (bs) {
bitrate=atoi(bs);
printf("\n");
}
+void
+waypt_status_disp(int total_ct, int myct)
+{
+ fprintf(stdout, "%d/%d/%d\r", myct*100/total_ct, myct, total_ct);
+ fflush(stdout);
+}
+
void
waypt_disp_all(waypt_cb cb)
{
waypointp = (waypoint *) elem;
if (global_opts.verbose_status) {
i++;
- fprintf(stdout, "%d/%d/%d\r", i*100/waypt_ct, i, waypt_ct);
- fflush(stdout);
+ waypt_status_disp(waypt_ct, i);
}
(*cb) (waypointp);
}